package action;

import conexao.FabricaDeConexao;
import dao.ConfirmaAcessoAdmDAO;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ConfAcessoADM extends HttpServlet {

    private static final long serialVersionUID = 1L;
    ConfirmaAcessoAdmDAO ConfAcessoAdmDAO;
    FabricaDeConexao conecta = new FabricaDeConexao();
    Connection conexao;
    Statement st;
    ResultSet rs;
    String query;

    public ConfAcessoADM() {
        super();
    }

    @Override
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
    }

    @Override
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        String senha = request.getParameter("txtSecreta");

        boolean resp;

        ConfirmaAcessoAdmDAO dao = new ConfirmaAcessoAdmDAO(conecta, conexao, null, null, query);
        resp = dao.ValidaAcesso(senha);

        if (resp) {
            response.sendRedirect("http://localhost:8080/ProjetoMarmitaria/faces/TelaAdministrativa.jsp");
        } else {
            response.sendRedirect("http://localhost:8080/ProjetoMarmitaria/faces/NegativaTelaAdministrativa.xhtml");
        }
    }
}
